package com.it.demo.controller;

import com.it.demo.pojo.Person;
import com.it.demo.service.PersonService;
import com.it.demo.utils.RedisUtil;
import org.omg.CORBA.ObjectHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/person")
public class PersonController {
    @Resource
    private PersonService personService;
    @Autowired
    private RedisUtil redisUtil;
    //进入查询页面
    @RequestMapping("PageHtml")
    public String PageHtml(){
        return "person";
    }
    @RequestMapping("getAll")
    @ResponseBody
    //@RequestParam("netherlands")String netherlands, @RequestParam("data")Date currd
    public Object getAll(){
        Map<String,Object> results=new HashMap<>();
        List<Person> all = personService.getAll();
        for (Person person : all) {
            System.out.println(person);
        }
        results.put("code",0);
        results.put("data",all);
        results.put("count",all.size());
        return results;
    }
}
